import { IsString, IsEnum, IsArray, IsNotEmpty, ArrayNotEmpty, IsNumber, IsOptional } from 'class-validator';

export const QuestionType = {
  CHOICE: 'CHOICE',
  MULTIPLE_CHOICE: 'MULTIPLE_CHOICE',
  TRUE_FALSE: 'TRUE_FALSE',
  SHORT_ANSWER: 'SHORT_ANSWER'
} as const;

export type QuestionType = typeof QuestionType[keyof typeof QuestionType];

export class CreateQuestionDto {
  @IsEnum(QuestionType)
  @IsNotEmpty({ message: '题目类型不能为空' })
  type: QuestionType;

  @IsString()
  @IsNotEmpty({ message: '科目不能为空' })
  subject: string;

  @IsString()
  @IsNotEmpty({ message: '题目内容不能为空' })
  content: string;

  @IsArray()
  @ArrayNotEmpty({ message: '选项不能为空' })
  options: string[];

  @IsString()
  @IsNotEmpty({ message: '答案不能为空' })
  answer: string;

  @IsString()
  @IsNotEmpty({ message: '题目解析不能为空' })
  explanation: string;

  @IsNumber()
  @IsOptional()
  score?: number = 1.0;
}